package com.example.servicesa

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import android.util.Log

/**
 * 测试的Services
 */
class TestServices : Service() {

    private val binder: IBinder = LocalBinder()

    inner class LocalBinder : Binder() {
        fun getService() :TestServices {
            return this@TestServices
        }
    }

    override fun onBind(intent: Intent?): IBinder? {
        Log.i("TestServices", "onBind")
        return binder
    }

    override fun onCreate() {
        Log.i("TestServices", "onCreate")
        super.onCreate()
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.i("TestServices", "onStartCommand")
        return START_STICKY
    }

    override fun onUnbind(intent: Intent?): Boolean {
        Log.i("TestServices", "onUnbind")
        return super.onUnbind(intent)
    }

    override fun onDestroy() {
        Log.i("TestServices", "onDestroy")
        super.onDestroy()
    }

}